package com.pubinfo.passbook.common.service.engine.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pubinfo.passbook.common.entity.TEnginePlaceholderEquation;
import com.pubinfo.passbook.common.mapper.TEnginePlaceholderEquationMapper;
import com.pubinfo.passbook.common.model.dto.engine.EngineConstParam;
import com.pubinfo.passbook.common.model.dto.engine.EngineEquationParam;
import com.pubinfo.passbook.common.service.engine.EngineComputePlaceHolderEquationService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @author zhouch
 * @date 2021/12/16 10:59
 */
@Service
public class EngineComputePlaceHolderEquationServiceImpl extends ServiceImpl<TEnginePlaceholderEquationMapper, TEnginePlaceholderEquation> implements EngineComputePlaceHolderEquationService {

    @Override
    public IPage<TEnginePlaceholderEquation> page(EngineEquationParam param) {
        Page<TEnginePlaceholderEquation> pager = param.getPage();

        return new LambdaQueryChainWrapper<>(baseMapper)
                .like(StringUtils.isNotBlank(param.getKeyword()), TEnginePlaceholderEquation::getName, param.getKeyword())
                .eq(StringUtils.isNotBlank(param.getChainType()), TEnginePlaceholderEquation::getChainType, param.getChainType())
                .page(pager);
    }
}
